package com.design.yjx.iterator.component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yuanjianxin
 * @date 2017/8/22 17:46
 */
public class Menu extends MenuComponent {
    private List<MenuComponent> menuComponents = new ArrayList<>();
    private String name;
    private String desc;

    public Menu(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }


    @Override
    public void add(MenuComponent menuComponent) {
        this.menuComponents.add(menuComponent);
    }

    @Override
    public void remove(MenuComponent menuComponent) {
        this.menuComponents.remove(menuComponent);
    }

    @Override
    public MenuComponent getChild(int i) {
        return this.menuComponents.get(i);
    }

    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public String getDescription() {
        return this.desc;
    }

    @Override
    public double getPrice() {
        return super.getPrice();
    }

    @Override
    public boolean isVegetarian() {
        return super.isVegetarian();
    }

    @Override
    public void print() {
        System.out.println("name = " + name + ",desc=" + desc);
        for (MenuComponent menuComponent : menuComponents) {
            menuComponent.print();
        }

    }
}
